#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import fitz

def pdf_to_images(pdf_path, output_folder):
    pdf_document = fitz.open(pdf_path)
    for page_number in range(len(pdf_document)):
        page = pdf_document.load_page(page_number)
        pix = page.get_pixmap()
        image_path = f"{output_folder}/page_{page_number + 1}.png"
        pix.save(image_path)
    pdf_document.close()

# 使用示例
pdf_to_images('example.pdf', 'output_images')